/*
 * @Author: weikang
 * @Description:
 * @Date: 2024-02-08 16:50:25
 * @LastEditTime: 2024-03-24 10:35:06
 * @FilePath: \env-manager-pc\src\api\modules\contract.ts
 */
import api from '../index'
import type { ContractRow } from './types/contract'
import type { EntListRes, QueryData } from './types/ent'

export default {
  // 合同列表
  GetContracts: (data: QueryData) => api<EntListRes<ContractRow>>({
    url: `/Obj/Contract/GetContracts`,
    method: 'post',
    data,
  }),
  // 合同修改
  ContractsUpdate: (data: { contractObjID: string, contract: ContractRow }) => api<ContractRow>({
    url: `/Obj/Contract/Update`,
    method: 'post',
    data,
  }),
  // 合同新增
  ContractsAdd: (data: { contract: ContractRow }) => api<ContractRow>({
    url: `/Obj/Contract/Add`,
    method: 'post',
    data,
  }),
  // 合同删除
  ContractsDelete: (data: { contractObjID: string }) => api({
    url: `/Obj/Contract/Delete`,
    method: 'post',
    data,
  }),
  // 上传合同文件
  AddContractFile: (data: { contractObjID: string, fileType: number, file: File }) => api({
    url: `/Obj/Contract/AddContractFile`,
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data',
    } as any,
    data,
  }),
  // 删除合同文件
  DeleteContractFile: (data: { contractObjID: string, fileType: number }) => api({
    url: `/Obj/Contract/DeleteContractFile`,
    method: 'post',
    data,
  }),
  // 获取合同文件
  GetContractFile: (data: { contractObjID: string, fileType: number }) => api({
    url: `/Obj/Contract/GetContractFile`,
    method: 'post',
    data,
    responseType: 'blob',
  }),
  // 合同及资产统计
  GetOwnerOrgStat: (data: { ownerOrgObjID: string }) => api<any>({
    url: `/Obj/Contract/GetOwnerOrgStat`,
    method: 'post',
    data,
  }),
}
